import Vue from 'vue'
import VueRouter from 'vue-router'
import NProgress from "nprogress"
import 'nprogress/nprogress.css'

Vue.use(VueRouter)

const routes = [
    {
        path: '/',
        name: 'logReg',
        component: () => import("../views/logReg")
    },
    {
        path: '/test',
        name: 'Test',
        component: () => import("../views/Test")
    },
    {
        path: '/home',
        name: 'Home',
        component: () => import("../views/Home"),
        children: [
            {
                path: '/',
                name: 'Index',
                component: () => import("../views/Summary")
            },
            {
                path: '/search',
                name: 'searchVue',
                component: () => import("../views/searchVue")
            },
            {
                path: '/analysis',
                name: 'analysisVue',
                component: () => import("../views/analysisVue")
            },
            {
                path: '/topic',
                name: 'topicVue',
                component: () => import("../views/topicVue")
            },
            {
                path: '/sentiment',
                name: 'sentimentVue',
                component: () => import("../views/sentimentVue")
            },
        ]
    },
    {
        path: '/user',
        name: 'perInfo',
        component: () => import("../views/perCenter")
    },
]

const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    routes
})
router.beforeEach(async (to, from, next) => {
    NProgress.start();
    next();
});

router.afterEach(() => {
    NProgress.done();
});

export default router
